﻿package mortal.game.view.guildNew.building
{
    import Message.DB.Tables.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import extend.language.*;
    import mortal.common.global.*;
    import mortal.game.resource.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.view.common.*;
    import mortal.game.view.guildNew.data.*;

    public class GuildNewBuildTip extends GSprite
    {
        protected var _bg:ScaleBitmap;
        protected var _top:GBitmap;
        protected var _nameT:GBitmap;
        protected var _curDes:GTextFiled;
        protected var _curTxt:GTextFiled;
        protected var _line:GBitmap;
        protected var _nextDes:GTextFiled;
        protected var _nextTxt:GTextFiled;
        protected var _fullTip:GTextFiled;

        public function GuildNewBuildTip()
        {
            var _loc_1:Boolean = false;
            this.mouseEnabled = false;
            this.mouseChildren = _loc_1;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bg = UIFactory.bg(0, 0, 212, 198, this, ImagesConst.ToolTipBg);
            this._top = UIFactory.gBitmap(ImagesConst.GuildNBuildingTip, 14, 20, this);
            this._nameT = UIFactory.gBitmap(ImagesConst.GuildNBuildingBN5, 81, 12, this);
            this._curDes = UIFactory.gTextField("" + Language.getString(71431), 11, 36, 100, 20, this, GlobalStyle.textFormatLv.setBold(true));
            this._curTxt = UIFactory.gTextField("" + Language.getString(71432), 13, 60, 190, 80, this);
            this._curTxt.multiline = true;
            this._curTxt.wordWrap = true;
            this._line = UIFactory.gBitmap(ImagesConst.SplitLine, 22, 105, this);
            this._nextDes = UIFactory.gTextField("" + Language.getString(71433), 11, 114, 100, 20, this, GlobalStyle.textFormatHong.setBold(true));
            this._nextTxt = UIFactory.gTextField("" + Language.getString(71434), 13, 137, 190, 80, this, GlobalStyle.textFormatHong);
            this._nextTxt.multiline = true;
            this._nextTxt.wordWrap = true;
            this._fullTip = UIFactory.gTextField("" + Language.getString(71435), 84, 118, 100, 20, this, GlobalStyle.textFormatHong);
            var _loc_1:Boolean = false;
            this._fullTip.mouseEnabled = false;
            var _loc_1:* = _loc_1;
            this._nextTxt.mouseEnabled = _loc_1;
            var _loc_1:* = _loc_1;
            this._nextDes.mouseEnabled = _loc_1;
            var _loc_1:* = _loc_1;
            this._curTxt.mouseEnabled = _loc_1;
            this._curDes.mouseEnabled = _loc_1;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._bg = null;
            this._top = null;
            this._nameT = null;
            this._curDes = null;
            this._curTxt = null;
            this._line = null;
            this._nextDes = null;
            this._nextTxt = null;
            this._fullTip = null;
            return;
        }// end function

        public function set data(param1) : void
        {
            var _loc_2:* = param1;
            if (_loc_2 == null)
            {
                return;
            }
            if (this._nameT)
            {
                this._nameT.dispose();
            }
            var _loc_3:* = GuildNewUtil.typeToIndex;
            var _loc_4:* = _loc_3[_loc_2.structureType];
            this._nameT = UIFactory.gBitmap(ImagesConst["GuildNBuildingBN" + _loc_4], 81, 12, this);
            this.updateCurLevel(_loc_2);
            this.updateNextLevel(_loc_2);
            this.layOut();
            return;
        }// end function

        private function updateCurLevel(param1:TGuildStructureConfig) : void
        {
            this._curTxt.htmlText = param1.descStr;
            return;
        }// end function

        private function updateNextLevel(param1:TGuildStructureConfig) : void
        {
            var _loc_4:TGuildStructureConfig = null;
            var _loc_2:* = param1.structureLevel;
            _loc_2 = _loc_2 == 0 ? (1) : (_loc_2);
            var _loc_3:* = GuildBuildingConfig.instance.getNextBuildingLvNeedGuildLv2(_loc_2, param1.structureType, param1.structureLevel);
            if (_loc_3 == -1)
            {
                this._fullTip.visible = true;
                this._nextDes.visible = false;
                this._nextTxt.visible = false;
                this._bg.height = 148;
            }
            else
            {
                this._fullTip.visible = false;
                this._nextDes.visible = true;
                this._nextTxt.visible = true;
                this._bg.height = 198;
                _loc_4 = GuildBuildingConfig.instance.getInfoByBuildingType(_loc_3, param1.structureType);
                this._nextTxt.htmlText = _loc_4.descStr;
            }
            return;
        }// end function

        private function layOut() : void
        {
            this._line.y = this._curTxt.y + this._curTxt.textHeight + 8;
            this._nextDes.y = this._line.y + 9;
            this._fullTip.y = this._line.y + 17;
            this._nextTxt.y = this._nextDes.y + 20;
            if (this._nextTxt)
            {
                this._bg.height = this._nextTxt.y + this._nextTxt.textHeight + 10;
            }
            else
            {
                this._bg.height = this._fullTip.y + this._fullTip.textHeight + 10;
            }
            return;
        }// end function

    }
}
